import React, { Component } from 'react'

// 这个函数，返回一个组件
export default (DecoratedComponent, styles) => {
   class NewComponent extends Component {
    componentWillMount() {
      const { staticContext } = this.props
      if (staticContext) {
        staticContext.css.push(styles._getCss())
      }
    }

    render() {
      return <DecoratedComponent {...this.props} />
    }
  }

  NewComponent.loadData = DecoratedComponent.loadData

  return NewComponent
}
